<link href="<?php echo base_url()?>/style/validationEngine.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="<?php echo base_url()?>script/jquery.validationEngine-<?php echo $this->lang->lang()!=''?$this->lang->lang():'en';?>.js"></script>
<script type="text/javascript" src="<?php echo base_url()?>script/jquery.validationEngine.js"></script>
<div class="middleFront">
    <div class="infoText infoTitle">
        <?php
            if($representatives[0]->message_status!=1 || $representatives[0]->message_status!=0){
                echo "Пораката e испратенa до следните претставници:";
            }else{
                echo "Пораката ќе биде испратенa до следните претставници:";

            }
        ?>
    </div>
    <ul class="informationHelp">
        <?php
            foreach ($representatives as $key=>$val) {
        
        ?>
        <li>
            <?php
                echo $val->rep_name." ".$val->rep_surname;
            ?>
        </li>
        <?php
            }
        ?>
    </ul>
    
    <div class="formHolder">
        
            <table width="100%" border="0" class="mainTableFormHolder">
            <tr>
                <td>
                    <table class="leftTable" width="100%">
                        <tr>
                            <td width="45%">
                                <b><?php echo lang('sender_name')?></b>
                                <img src="<?php echo base_url()."style/images/musthave.png"?>" alt="<?php echo lang('case_field_required')?>" title="<?php echo lang('case_field_required')?>" />
                            </td>
                            <td width="55%"><?php echo $sendData['sender_name'];?></td>
                        </tr>
                        <tr>
                            <td width="45%">
                                <b><?php echo lang('sender_address')?></b>
                                <img src="<?php echo base_url()."style/images/musthave.png"?>" alt="<?php echo lang('case_field_required')?>" title="<?php echo lang('case_field_required')?>" />
                            </td>
                            <td width="55%"><?php echo $sendData['sender_address'];?></td>
                        </tr>
                        <tr>
                            <td width="45%">
                                <b><?php echo lang('sender_city')?></b>
                                <img src="<?php echo base_url()."style/images/musthave.png"?>" alt="<?php echo lang('case_field_required')?>" title="<?php echo lang('case_field_required')?>" />
                            </td>
                            <td width="55%"><?php echo $sendData['sender_city'];?></td>
                        </tr>
                        <tr>
                            <td width="45%">
                                <b><?php echo lang('municipality_id')?></b>
                                <img src="<?php echo base_url()."style/images/musthave.png"?>" alt="<?php echo lang('case_field_required')?>" title="<?php echo lang('case_field_required')?>" />
                            </td>
                            <td width="55%"></td>
                        </tr>
                    </table>
                </td>
                <td>
                    <table class="rightTable">
                        <tr>
                            <td width="45%">
                               <b><?php echo lang('sender_email')?></b>
                               <img src="<?php echo base_url()."style/images/musthave.png"?>" alt="<?php echo lang('case_field_required')?>" title="<?php echo lang('case_field_required')?>" />
                            </td>
                            <td width="55%"><?php echo $sendData['sender_email']; ?></td>
                        </tr>
                        <tr>
                            <td width="45%">
                               <b><?php echo lang('sender_phone')?></b>
                            </td>
                            <td width="55%"><?php echo $sendData['sender_phone']; ?></td>
                        </tr>
                        <tr>
                            <td width="45%">
                               &nbsp;
                            </td>
                            <td width="55%">&nbsp;</td>
                        </tr>
                    </table>
                </td>
            </tr>
            <tr>
                <td class="textareaHelper">
                    <b><?php echo lang('message')?></b>
                    <img src="<?php echo base_url()."style/images/musthave.png"?>" alt="<?php echo lang('case_field_required')?>" title="<?php echo lang('case_field_required')?>" />
                </td>
                <td>&nbsp;</td>
            </tr>
            <tr>
                <td colspan="2" class="textareaHelper">
                    <textarea name="message" id="message" class="stiliziran textMail validate[required]" cols="45" rows="15" readonly><?php echo $sendData['message']; ?></textarea>
                </td>
            </tr>
            <tr>
                <td colspan="2" class="textareaHelper"><h3><?php echo  lang('answer_from');?></h3></td>
                
            </tr>
            <?php

                foreach ($representatives as $key=>$val) {

                    if($val->answer_message!=null){
             ?>
            <tr>
                <td colspan="2" class="textareaHelper">
                    <h4><?php echo $val->rep_name." ".$val->rep_surname;?></h4>
                    <p><?php echo $val->answer_message;?></p>
                </td>
                
            </tr>
            <?php
                    }

                }
            ?>
            <?php
            if($representatives[0]->message_status==0){
            ?>
               <tr>
                    <td class="textareaHelper">
                        <div class="returnBack">
                            <a href="javascript:history.go(-1);"><?php echo lang('go_back')?></a>
                        </div>
                    </td>
                    <td>
                        &nbsp;
                    </td>
                </tr>

            <?php
            }else{
            ?>

                 <tr>
                    <td class="textareaHelper">
                        <div class="returnBack">
                            <a href="<?php echo base_url()."mk/admin/messages/approval/".$sendData['message_id']?>"><?php echo lang('approve_message')?></a>
                        </div>
                    </td>
                    <td class="textareaHelper">
                        <div class="sendMessage">
                            <a href="<?php echo base_url()."mk/admin/messages/deleteMessage/".$sendData['message_id']?>"><?php echo lang('delete_message')?></a>
                        </div>
                    </td>
                </tr>

            <?php
            }
            ?>
        </table>
    </div>
    <div class="cleardiv"></div>
</div>
<script type="text/javascript">
    $(document).ready(function(){
//        $("form[name=messageForm]").validationEngine();
    });
    $('#preview_message').click(function(){
        $('form[name=messageForm]').submit();
    });
</script>

